import java.text.DecimalFormat;

/**
 * Create by xiaoye on 2023/8/11
 */

public class FormatDecimal {
    public static double round(double number) {
        DecimalFormat decimalFormat = new DecimalFormat("#.00");
        return Double.parseDouble(decimalFormat.format(number));
    }

    public static void main(String[] args) {
        double number = 3.14559;
        double roundedNumber = round(number);
        String test = Double.toString(roundedNumber);
        System.out.println(test);
        System.out.println(roundedNumber);
    }
}
